<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.23.
   家居公司积分配置模型($$)*/

!defined('Q_PATH') && exit;

class JiajucreditconfigModel extends CommonModel{

	static public function init__(){
		return array(
			'table_name'=>'jiajucreditconfig',
			'check'=>array(
				'jiajucreditconfig_name'=>array(
					array('require',Q::L('配置的积分名称不能为空','__APPJIAJU_COMMON_LANG__@Model')),
					array('max_length',50,Q::L('配置的积分名称不能超过50个字符','__APPJIAJU_COMMON_LANG__@Model')),
				),
				'jiajucreditconfig_addtips'=>array(
					array('max_length',250,Q::L('增加积分的提示不能超过250个字符','__APPJIAJU_COMMON_LANG__@Model')),
				),
				'jiajucreditconfig_cuttips'=>array(
					array('max_length',250,Q::L('减少积分的提示不能超过250个字符','__APPJIAJU_COMMON_LANG__@Model')),
				),
				'jiajucreditconfig_counttips'=>array(
					array('max_length',250,Q::L('积分到上限的时候的提示不能超过250个字符','__APPJIAJU_COMMON_LANG__@Model')),
				),
				'jiajucreditconfig_monthtips'=>array(
					array('max_length',250,Q::L('月积分达到上限次数后的提示不能超过250个字符','__APPJIAJU_COMMON_LANG__@Model')),
				),
				'jiajucreditconfig_module'=>array(
					array('require',Q::L('配置的模块不能为空','__APPJIAJU_COMMON_LANG__@Model')),
					array('max_length',30,Q::L('配置的模块不能超过30个字符','__APPJIAJU_COMMON_LANG__@Model')),
					array('moduleName',Q::L('配置的模块已经存在','__APPJIAJU_COMMON_LANG__@Model'),'condition'=>'must','extend'=>'callback'),
				),
			),
		);
	}

	static function F(){
		$arrArgs=func_get_args();
		return ModelMeta::instance(__CLASS__)->findByArgs($arrArgs);
	}

	static function M(){
		return ModelMeta::instance(__CLASS__);
	}
	
	public function moduleName(){
		if(!isset($_POST['jiajucreditconfig_module'])){
			return true;
		}
		return $this->uniqueField_('jiajucreditconfig_module','jiajucreditconfig_id','value');
	}

	protected function beforeSave_(){
		$this->jiajucreditconfig_name=C::text($this->jiajucreditconfig_name);
		$this->jiajucreditconfig_addtips=C::text($this->jiajucreditconfig_addtips);
		$this->jiajucreditconfig_cuttips=C::text($this->jiajucreditconfig_cuttips);
		$this->jiajucreditconfig_counttips=C::text($this->jiajucreditconfig_counttips);
		$this->jiajucreditconfig_monthtips=C::text($this->jiajucreditconfig_monthtips);
		$this->jiajucreditconfig_module=C::text($this->jiajucreditconfig_module);
	}

}
